<?php
session_start();
include_once 'recursos/funciones.php';
include_once 'recursos/lang.properties.php';
$lang = new langProperties();
validarDatosPerfil();

$hasSystemName = true;
$hasMail = true;
$hasBirth = true;
$hasFName = true;
$hasLName = true;
$hasPPic = true;
$showDialog = false;

if($_SESSION["g2uSystemName"]==""){
    $hasSystemName = false;
    $showDialog = true;
}
if($_SESSION["g2uMail"]==""){
    $hasMail = false;
    $showDialog = true;
}
if($_SESSION["g2uBirthday"]=="00-00-0000"){
    $hasBirth = false;
    $showDialog = true;
}
if($_SESSION["g2uFirstName"]==""){
    $hasFName = false;
    $showDialog = true;
}
if($_SESSION["g2uLastName"] ==""){
    $hasLName = false;
    $showDialog = true;
}
        
        
//$_SESSION["g2uName"] 
//$_SESSION["g2uProfilePic"] = $fila["user_profile_pic"];

?>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title> :: Gift 2 You :: <?=$_SESSION["g2uUserName"]?></title>

        <link rel="shortcut icon" type="image/ico" href="images/vineta-globo.png" >
        <link type="text/css" href="css/g2u.css" rel="stylesheet" media="screen" />
        <link type="text/css" href="css/tipsy.css" rel="stylesheet"  media="screen" />
        <link type="text/css" href="css/jquery-ui.css" rel="stylesheet"  media="screen" />

        <script lang="javascript" type="text/javascript" src="js/jquery-1.9.1.js"></script>
        <script lang="javascript" type="text/javascript" src="js/g2u.js"></script>
        <script lang="javascript" type="text/javascript" src="js/tipsy.js"></script>
        <script lang="javascript" type="text/javascript" src="js/jquery-ui.js"></script>
        <script lang="javascript" type="text/javascript" src="js/floating.js"></script>
        <script>
        
        <? 
        if ($_SESSION["g2uFirstTime"] == true){
            ?>
            setTimeout(function (){$("#para").slideUp(1500);}, 7500);
            setTimeout(function (){$("#como").slideUp(1500);}, 15000);
            <?
        }
        ?>
            $(document).ready(function(){
               $.post('nubes.php', function(data){
                   $("html").append(data);
               });
               
               $("#Noticias").tipsy({html: true, fade: true, gravity:'s' });
               $("#Perfil").tipsy({html: true, fade: true, gravity:'e' });
               $("#Wishlist").tipsy({html: true, fade: true, gravity:'w' });
               $("#Amigos").tipsy({html: true, fade: true, gravity:'e' });
               $("#Eventos").tipsy({html: true, fade: true, gravity:'w' });
               
               
               setTimeout(function (){$("#Amigos").tipsy("show");}, 1000);
               setTimeout(function (){$("#Amigos").tipsy("hide");}, 5000);
               setTimeout(function (){$("#Perfil").tipsy("show");}, 5000);
               setTimeout(function (){$("#Perfil").tipsy("hide");}, 10000);
               setTimeout(function (){$("#Noticias").tipsy("show");},10000 );
               setTimeout(function (){$("#Noticias").tipsy("hide");}, 15000);
               setTimeout(function (){$("#Wishlist").tipsy("show");}, 15000);
               setTimeout(function (){$("#Wishlist").tipsy("hide");}, 20000);
               setTimeout(function (){$("#Eventos").tipsy("show");}, 20000);
               setTimeout(function (){$("#Eventos").tipsy("hide");}, 25000);
               
               $.floatingMessage("<div style='cursor:pointer' onclick='$(\"#como\").fadeIn(1200,function(){setTimeout(function (){$(\"#como\").fadeOut(1200);}, 10000)})'>¿Nuevo en G2U? <br/> ¿Como empezar en Gift To You?</div>",{
                    show : "fold",
                    hide : "explode",
                    position : "bottom-left"
               });
               
            });
            
            
        </script>
        <style>
            .ui-dialog-title{
                font-family: g2u;
                font-size: 11pt;
            }
        </style>
    </head>
    <body>
        <table cellpadding="0" cellspacing="0" style="width: 100%; height: 100%; border-color: lightgray; padding-right: 100px;" border="0">
            <tr>
                <td style="width: 25%; vertical-align: top;">
                    <div>
                        <!-- Logo G2U -->
                        <center>
                            <img src="images/logo.png"/>
                        </center>
                    </div>
                </td>
                <td style="width: 75%; vertical-align: top;">
                    <!--<div>
                        <img src="images/texto.png"  />
                    </div> -->
                    <div id="head">
           
                            <b>
                                <img id="ppicPortal" src="<?=$_SESSION["g2uProfilePic"]?>" />
                                <?=$_SESSION["g2uFirstName"]?> 
                                <!--<img src="images/fb-logout.png" style="cursor: pointer;" onclick="logOut();" />-->
                                <img src="images/png/salir.png" style="cursor: pointer;" onclick="logOut();"  width="18px" />
                            </b>
              
                        <br/>
                    </div>
                    <div id="fb-root"></div>
                    
                </td>
            </tr>
            <tr>
                <td colspan="2" style="vertical-align: top">
                    <center>
                        <? 
                        if ($_SESSION["g2uFirstTime"] == true){
                            ?>
                            <img src="images/para_que.jpg" id="para" height="370" />
                            <br/>
                            <img src="images/como.jpg" id="como" height="420" />
                            <?
                        } else {
                             ?>
                            <img src="images/para_que.jpg" id="para" height="370" style="display: none;" />
                            <img src="images/como.jpg" id="como" height="420" style="display: none;" />
                            <?
                        }
                        ?>
                        <table border="0" cellspacing="0" cellpadding="15" style="height: 300px; width: 65%;">
                            <tr>
                                <td colspan="4">
                                    <center><img src="images/btn_c/btn_noticias.png" id="Noticias" alt="<?=$lang->get_noticias_es()?>" title="<?=$lang->get_noticias_es()?>" /></center>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <center><img src="images/btn_c/btn_perfil.png" id="Perfil" alt="<?=$lang->get_perfil_es()?>" title="<?=$lang->get_perfil_es()?>" /></center>
                                </td>
                                <td colspan="2">
                                    <center><img src="images/btn_c/btn_wishlist.png" id="Wishlist" alt="<?=$lang->get_wishlist_es()?>" title="<?=$lang->get_wishlist_es()?>" /></center>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <center><img src="images/btn_c/btn_amigos.png" id="Amigos" alt="<?=$lang->get_amigos_es()?>" title="<?=$lang->get_amigos_es()?>" /></center>
                                </td>
                                <td colspan="2" width="33%">
                                </td>
                                <td>
                                    <center><img src="images/btn_c/btn_eventos.png" id="Eventos" alt="<?=$lang->get_eventos_es()?>" title="<?=$lang->get_eventos_es()?>" /></center>
                                </td>
                            </tr>
                            <tr>
                                <td>
                                    <img src="images/png/bici.png" id="bicicle" style="position:absolute; z-index: -100" />
                                </td>
                                <td colspan="2" width="33%">
                                    <img src="images/png/bici.png" id="bicicle2" style="position:absolute; z-index: -150" />
                                    <center><img src="images/btn_c/btn_inicio.png" id="Inicio" /></center>
                                </td>
                                <td>
                                </td>
                            </tr>
                        </table>
                    </center>
                </td>
            </tr>
        </table>
       
        <!-- FACEBOOK JAVASCRIPT - INICIO -->
        <script>
          window.fbAsyncInit = function() {
          FB.init({
            appId      : '1398829387019074', // App ID
            channelUrl : '//g2u.com.pe/channel.html',
            status     : true, // check login status
            cookie     : true, // enable cookies to allow the server to access the session
            xfbml      : true  // parse XFBML
          });
        
            $(document).trigger('fbload');

            FB.Event.subscribe('auth.authResponseChange', function(response) {
                if (response.status === 'connected') {
                    //cambiarEstadoSession();
                }
            });

          };
          
          

          (function(d){
            var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
            if (d.getElementById(id)) {return;}
            js = d.createElement('script'); js.id = id; js.async = true;
            js.src = "//connect.facebook.net/en_US/all.js";
            //js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=1398829387019074";
            ref.parentNode.insertBefore(js, ref);
          }(document));

        </script>
        
        <script>
            $(document).on(
                'fbload',
                function(){
                    FB.getLoginStatus(function(res){
                        if (res.status == "connected") {
                            
                            FB.api('/me', function(user){
                                $("#logout").show();
                            });
                            
                        }
                    });
                }
            );
        </script>
        
        <script>
            
            $(document).ready(function(){
                <? 
                if ($_SESSION["g2uFirstTime"] == true){
                    ?>
                    setTimeout("sliderG2U()", 17000);
                <?
                } else {
                    ?>
                    sliderG2U();
                    <?
                }
                ?>
            });
            
            function sliderG2U(){
                $("#bicicle").animate({ 
                    left: "+=600px",
                }, 7500, "linear", function() {
                    $("#bicicle").toggle(1500);
                });

                $("#bicicle2").animate({ 
                    left: "+=300px",
                }, 6000, "linear", function() {
                    $("#bicicle2").toggle(1500);
                });
            }
            
            <? 
            if ($showDialog){
              ?>
                $(function() {
                    $( "#dialog" ).dialog();
                });         
              <?
            }
            ?>

         </script>
         
         <div id="dialog" title="Ten en cuenta lo siguiente:" style="display: none; font-family: g2u; font-size: 10pt;">
<p>
<?
if(!$hasSystemName){
    echo $lang->get_noSystemName_es();
}
if(!$hasMail){
    echo $lang->get_noMail_es();
}
if(!$hasBirth){
    echo $lang->get_noBirth_es();
}
if(!$hasFName){
    echo $lang->get_noFName_es();
}
if(!$hasLName){
    echo $lang->get_noLName_es();
}
?>
<center>
    Pero puedes hacerlo aquí!<br/>
    <a href="/perfil" style="border: none;">
        <img src="images/btn_c/btn_perfil.png" style="border: none;" />
    </a>
</center>
</p>
</div>         
    </body>
</html>